﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Windows.Forms;
using DevComponents.DotNetBar.Controls;
using DevComponents.DotNetBar;
using DevComponents.Editors.DateTimeAdv;
using QLTB.Controllers;
using QuanLyThietBi.Manager;
using QuanLyThietBi.ManagerBase;
using QuanLyThietBi.Entity;

namespace QLTB.Controllers
{
    public class TBL_NhomQuanLyCtrl
    {
        

        public void HienthiDGV(DataGridViewX DGV, BindingNavigator BN)
        {
            BindingSource BS = new BindingSource();
            BS.DataSource = TBL_NhomQuanLyManager.CreateInstant().LayDanhSachNhomQuanLy();
            BN.BindingSource = BS;
            DGV.DataSource = BS;
        }
        public void ThemMoiNhomNguoiDung(string MaNhom, string TenNhom, string MoTa)
        {
            TBL_NhomQuanLyEntity objNhom = new TBL_NhomQuanLyEntity();
            objNhom.MaNhomQuanLy = MaNhom;
            objNhom.TenNhomQuanLy = TenNhom;
            objNhom.Mota = MoTa;
            TBL_NhomQuanLyManager.CreateInstant().Insert(objNhom);
        }
        public void CapNhatNhomNguoiDung(string MaNhom, string TenNhom, string MoTa)
        {
            TBL_NhomQuanLyEntity objNhom = new TBL_NhomQuanLyEntity();
            objNhom.MaNhomQuanLy = MaNhom;
            objNhom.TenNhomQuanLy = TenNhom;
            objNhom.Mota = MoTa;
            TBL_NhomQuanLyManager.CreateInstant().Update(objNhom);
        }
        public void XoaDong(string sMaNhom)
        {
            TBL_NhomQuanLyManager.CreateInstant().DeleteByMaNhomQuanLy(sMaNhom);
        }
        public void HienThiComboBoxNhomQuanLy(ComboBoxEx cb)
        {
            cb.DataSource = TBL_NhomQuanLyManager.CreateInstant().SelectAll();
            cb.DisplayMember = "TenNhomQuanLy";
            cb.ValueMember = "MaNhomQuanLy";
        }
       

    }
}
